package com.senta.elasticsearch.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;


/**
 * <p>
 *
 * </p>
 *
 * @author anyang
 * @since 2019-11-19
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Document(indexName = "billing", type = "billingitemdis")
@TableName("billing_item_dis")
public class BillingItemDis implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     * 要求传入ES时必须设置
     */
    @TableId
    @Id
    @Field(type = FieldType.Keyword)
    @NonNull
    private String pk;

    /**
     * 项目类别编码
     */
    @Field(type = FieldType.Text)
    private String itemClass1;

    /**
     * 项目类别名称
     */
    @Field(type = FieldType.Keyword)
    private String itemClass2;

    /**
     * 项目编码
     */
    @Field(type = FieldType.Text)
    private String itemCode;

    /**
     * 项目名称
     */
    @Field(type = FieldType.Text)
    private String itemName;

    /**
     * 项目规格
     */
    @Field(type = FieldType.Text)
    private String itemSpec;

    /**
     * 数量
     */
    @Field(type = FieldType.Integer)
    private String amount;

    /**
     * 最小单位
     */
    @Field(type = FieldType.Text)
    private String units;

    /**
     * 金额
     */
    @Field(type = FieldType.Double)
    private String charges;

    /**
     * 执行科室
     */
    @Field(type = FieldType.Text)
    private String performDept;

    /**
     * 执行医生
     */
    @Field(type = FieldType.Keyword)
    private String performDoctor;

    /**
     * 开单科室
     */
    @Field(type = FieldType.Text)
    private String orderDept;
    /**
     * 开单医生id
     */
    @Field(type = FieldType.Keyword)
    private String orderDoctorId;

    /**
     * 开单医生
     */
    @Field(type = FieldType.Keyword)
    private String orderDoctor;

    /**
     * 住院号
     */
    @Field(type = FieldType.Long)
    private Long serialNumber;

    /**
     * 医疗小组ID
     */
    @Field(type = FieldType.Text)
    private String ylxzDoctors;

    /**
     * 计价时间
     */
    @Field(type = FieldType.Date)
    private Date billingDateTime;
    /**
     * 病人ID,用做关联
     */
    @Field(type = FieldType.Keyword)
    private String patientId;

    /**
     * 主页ID,用做关联
     */
    @Field(type = FieldType.Keyword)
    private String visitId;

    /**
     * 患者姓名
     */
    @Field(type = FieldType.Keyword)
    private String patientName;
    /**
     *  类型，住院、门特
     */
    @Field(type = FieldType.Keyword)
    private String hosOutp;

    /**
     * 自定义all字段，用于不知道条件的模糊插叙，会占用对应的内存，不建议自己设置；
     * 当未设置时，默认会拼接所有字段
     */
    @TableField(exist = false)
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_max_word")
    private String all;

    public BillingItemDis(){
    }


    public Integer getAmount(){
        return Integer.valueOf(amount);
    }

    public void setAmount(Integer amount){
        this.amount = amount.toString();
    }

    public String getAll(){
        return pk+
                " " + itemClass1+
                " " + itemClass2+
                " " + itemCode+
                " " + itemName+
                " " + itemSpec+
                " " + charges+
                " " + performDept+
                " " + performDoctor+
                " " + orderDept+
                " " + orderDoctor+
                " " + serialNumber+
                " " + billingDateTime+
                " " + patientName+
                " " + hosOutp+
                " " + ylxzDoctors;
    }

}
